<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>map、join、filter</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }
        h5 {
            margin: 10px;
            font-size: 20px;
        }
    </style>
</head>
<body>
<h5>map</h5>
<ul>
    <li>map</li>
    <li>join</li>
    <li>filter</li>
</ul>
<script>
    // 1.map 操作数组
    const map_date = [1,2,3,4,5]
    let new_map = map_date.map(function (item, index) {
        return item + 3
    })
    console.log(new_map)

    // 2.join 拼接数组
    const girlfriend_list = ["阿慧","小平","老朱"]
    const new_list = girlfriend_list.join("-")
    console.log(new_list)

    // 3.filter 过滤字符串
    const character = ["ass","tit","long leg","face","episode"]
    let best_character = character.filter((item,index)=>{
        if (item === "ass"){
            return true
        } else if (item === "tit"){
            return true
         } else if (item === "long leg"){
        return true
        } else {
            return false
        }
    })
    console.log(best_character)
    // 4.reduce方法
    const num_list = [1,2,3,4,5]
    let addition = num_list.reduce(function (pre,current){
        return pre + current
    })
    console.log(addition)

    // 5.find与findIndex方法
    const people = [
        {
        name: "python",
        age: 18,
        height: 188
        },
        {
            name: "java",
            age: 19,
            height: 186
        },
    ]
    const skill = people.find(function (item){
        return item.name === "java"
    })
    console.log(skill)
    const skill1 = people.findIndex(function (item){
        return item.name === "java"
    })
    console.log(skill1)

    // 6.every与some方法
    const num = [2,10,23,45]
    const result = num.every(item=>{
        return item >10
    })
    console.log(result)
    const result1 = num.some(item=>{
        return item >10
    })
    console.log(result1)
    // 7.Array.from方法 伪数组转化为
    console.log("--------")
    let li_list = document.querySelectorAll("li")
    li = Array.from(li_list)
    console.log(li)
</script>
</body>
</html>